package main

func longestSubsequence(arr []int, difference int) int {
	dp := make(map[int]int)
	max := 0
	for _, v := range arr {
		dp[v] = dp[v-difference] + 1
		if dp[v] > max {
			max = dp[v]
		}
	}
	return max
}